package com.hjq.demo.yuliao.activity

import android.content.Context
import android.content.Intent
import androidx.recyclerview.widget.GridLayoutManager
import com.gyf.immersionbar.ImmersionBar
import com.hjq.demo.R
import com.hjq.demo.app.vb.AppVbActivity
import com.hjq.demo.databinding.ActivityBackPackBinding
import com.hjq.demo.utils.CommonSpaceItemDecoration
import com.hjq.demo.yuliao.adapter.BackPackAdapter

class BackPackActivity : AppVbActivity<ActivityBackPackBinding>() {

    companion object {

        private const val INTENT_KEY_INFO: String = "info"

        fun start(context: Context, info: String) {
            val intent = Intent(context, BackPackActivity::class.java)
            intent.putExtra(INTENT_KEY_INFO, info)
            context.startActivity(intent)
        }
    }

    private var mAdapter: BackPackAdapter? = null

    override fun initView() {
        ImmersionBar.setTitleBar(this, binding.ivBackpackBg)

        binding.recyclerGift.layoutManager = GridLayoutManager(this, 3)
        mAdapter = BackPackAdapter()
        binding.recyclerGift.addItemDecoration(
            CommonSpaceItemDecoration(
                resources.getDimension(R.dimen.dp_10).toInt(),
                false, CommonSpaceItemDecoration.GRIDLAYOUT
            )
        )
        binding.recyclerGift.adapter = mAdapter

    }

    override fun initData() {
        val mList= mutableListOf<String>()
        mList.add("1")
        mList.add("1")
        mList.add("1")
        mList.add("1")
        mList.add("1")
        mList.add("1")
        mAdapter?.setNewInstance(mList)
    }
}